Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
456ef978
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
456ef978
编写于
12月 16, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2428
上级
e0d113b1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
8 deletion
+44
-8
src/sync/inc/syncMsg.h
src/sync/inc/syncMsg.h
+7
-2
src/sync/src/syncMsg.c
src/sync/src/syncMsg.c
+17
-0
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+10
-4
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+10
-2
未找到文件。
src/sync/inc/syncMsg.h
浏览文件 @
456ef978
...
...
@@ -35,7 +35,9 @@ typedef enum {
TAOS_SMSG_STATUS_RSP
=
10
,
TAOS_SMSG_SETUP
=
11
,
TAOS_SMSG_SETUP_RSP
=
12
,
TAOS_SMSG_END
=
13
,
TAOS_SMSG_SYNC_FILE
=
13
,
TAOS_SMSG_SYNC_FILE_RSP
=
14
,
TAOS_SMSG_END
=
15
,
}
ESyncMsgType
;
typedef
enum
{
...
...
@@ -116,7 +118,7 @@ typedef struct {
#pragma pack(pop)
#define SYNC_PROTOCOL_VERSION
0
#define SYNC_PROTOCOL_VERSION
1
#define SYNC_SIGNATURE ((uint16_t)(0xCDEF))
extern
char
*
statusType
[];
...
...
@@ -131,6 +133,9 @@ void syncBuildSyncDataMsg(SSyncMsg *pMsg, int32_t vgId);
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
);
#ifdef __cplusplus
}
#endif
...
...
src/sync/src/syncMsg.c
浏览文件 @
456ef978
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tchecksum.h"
#include "syncInt.h"
...
...
@@ -92,3 +93,19 @@ void syncBuildPeersStatus(SPeersStatus *pMsg, int32_t vgId) {
pMsg
->
head
.
len
=
sizeof
(
SPeersStatus
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
void
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
)
{
memset
(
pMsg
,
0
,
sizeof
(
SFileAck
));
pMsg
->
head
.
type
=
TAOS_SMSG_SYNC_FILE_RSP
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SFileAck
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
)
{
memset
(
pMsg
,
0
,
sizeof
(
SFileInfo
));
pMsg
->
head
.
type
=
TAOS_SMSG_SYNC_FILE
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SFileInfo
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
\ No newline at end of file
src/sync/src/syncRestore.c
浏览文件 @
456ef978
...
...
@@ -69,7 +69,13 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
minfo
.
index
=
-
1
;
int32_t
ret
=
taosReadMsg
(
pPeer
->
syncFd
,
&
minfo
,
sizeof
(
SFileInfo
));
if
(
ret
!=
sizeof
(
SFileInfo
)
||
minfo
.
index
==
-
1
)
{
sError
(
"%s, failed to read file info while restore file since %s"
,
pPeer
->
id
,
strerror
(
errno
));
sError
(
"%s, failed to read fileinfo while restore file since %s"
,
pPeer
->
id
,
strerror
(
errno
));
break
;
}
ret
=
syncCheckHead
((
SSyncHead
*
)(
&
minfo
));
if
(
ret
!=
0
)
{
sError
(
"%s, failed to check fileinfo while restore file since %s"
,
pPeer
->
id
,
strerror
(
ret
));
break
;
}
...
...
@@ -94,12 +100,12 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
&
sinfo
.
fversion
);
// if file not there or magic is not the same, file shall be synced
memset
(
&
fileAck
,
0
,
sizeof
(
fileAck
)
);
syncBuildFileAck
(
&
fileAck
,
pNode
->
vgId
);
fileAck
.
sync
=
(
sinfo
.
magic
!=
minfo
.
magic
||
sinfo
.
name
[
0
]
==
0
)
?
1
:
0
;
// send file ack
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
f
ileAck
));
if
(
ret
!=
sizeof
(
f
ileAck
))
{
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
SF
ileAck
));
if
(
ret
!=
sizeof
(
SF
ileAck
))
{
sError
(
"%s, failed to write file:%s ack while restore file since %s"
,
pPeer
->
id
,
minfo
.
name
,
strerror
(
errno
));
break
;
}
...
...
src/sync/src/syncRetrieve.c
浏览文件 @
456ef978
...
...
@@ -99,6 +99,7 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
while
(
1
)
{
// retrieve file info
syncBuildFileInfo
(
&
fileInfo
,
pNode
->
vgId
);
fileInfo
.
name
[
0
]
=
0
;
fileInfo
.
size
=
0
;
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
...
...
@@ -106,8 +107,8 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
sDebug
(
"%s, file:%s info is sent, size:%"
PRId64
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
size
);
// send the file info
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
f
ileInfo
));
if
(
ret
!=
sizeof
(
f
ileInfo
))
{
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
SF
ileInfo
));
if
(
ret
!=
sizeof
(
SF
ileInfo
))
{
code
=
-
1
;
sError
(
"%s, failed to write file:%s info while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
...
...
@@ -128,6 +129,13 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
break
;
}
ret
=
syncCheckHead
((
SSyncHead
*
)(
&
fileAck
));
if
(
ret
!=
0
)
{
code
=
-
1
;
sError
(
"%s, failed to check file:%s ack while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
ret
));
break
;
}
// set the peer sync version
pPeer
->
sversion
=
fileInfo
.
fversion
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录