Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21191ae2
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看板
提交
21191ae2
编写于
5月 31, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(sync): add SSyncSnapshotReceiver
上级
6d8733a2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
18 deletion
+99
-18
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+9
-7
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+90
-11
未找到文件。
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
21191ae2
...
...
@@ -56,20 +56,22 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
typedef
struct
SSyncSnapshotReceiver
{
bool
start
;
int32_t
ack
;
void
*
pWriter
;
void
*
pCurrentBlock
;
int32_t
len
;
bool
start
;
int32_t
ack
;
void
*
pWriter
;
void
*
pCurrentBlock
;
int32_t
blockLen
;
SyncTerm
term
;
SSyncNode
*
pSyncNode
;
int32_t
replicaIndex
;
}
SSyncSnapshotReceiver
;
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
);
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
,
int32_t
replicaIndex
);
void
snapshotReceiverDestroy
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverStart
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
);
int32_t
snapshotReceive
(
SSyncSnapshotReceiver
*
pReceiver
);
cJSON
*
snapshotReceiver2Json
(
SSyncSnapshotReceiver
*
pReceiver
);
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
);
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
21191ae2
...
...
@@ -115,10 +115,6 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender) {
taosMemoryFree
(
pSender
->
pCurrentBlock
);
pSender
->
blockLen
=
0
;
}
ret
=
pSender
->
pSyncNode
->
pFsm
->
FpSnapshotDoRead
(
pSender
->
pSyncNode
->
pFsm
,
pSender
->
pReader
,
&
(
pSender
->
pCurrentBlock
),
&
(
pSender
->
blockLen
));
ASSERT
(
ret
==
0
);
}
// send msg from seq, seq is already updated
...
...
@@ -206,19 +202,102 @@ char *snapshotSender2Str(SSyncSnapshotSender *pSender) {
}
// -------------------------------------
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
)
{
return
NULL
;
}
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
,
int32_t
replicaIndex
)
{
ASSERT
(
pSyncNode
->
pFsm
->
FpSnapshotStartWrite
!=
NULL
);
ASSERT
(
pSyncNode
->
pFsm
->
FpSnapshotStopWrite
!=
NULL
);
ASSERT
(
pSyncNode
->
pFsm
->
FpSnapshotDoWrite
!=
NULL
);
SSyncSnapshotReceiver
*
pReceiver
=
taosMemoryMalloc
(
sizeof
(
SSyncSnapshotReceiver
));
ASSERT
(
pReceiver
!=
NULL
);
memset
(
pReceiver
,
0
,
sizeof
(
*
pReceiver
));
pReceiver
->
start
=
false
;
pReceiver
->
ack
=
SYNC_SNAPSHOT_SEQ_BEGIN
;
pReceiver
->
pWriter
=
NULL
;
pReceiver
->
pCurrentBlock
=
NULL
;
pReceiver
->
blockLen
=
0
;
pReceiver
->
pSyncNode
=
pSyncNode
;
pReceiver
->
replicaIndex
=
replicaIndex
;
pReceiver
->
term
=
pSyncNode
->
pRaftStore
->
currentTerm
;
return
pReceiver
;
}
void
snapshotReceiverDestroy
(
SSyncSnapshotReceiver
*
pReceiver
)
{
if
(
pReceiver
!=
NULL
)
{
taosMemoryFree
(
pReceiver
);
}
}
void
snapshotReceiverStart
(
SSyncSnapshotReceiver
*
pReceiver
)
{
if
(
!
(
pReceiver
->
start
))
{
pReceiver
->
ack
=
SYNC_SNAPSHOT_SEQ_BEGIN
;
int32_t
ret
=
pReceiver
->
pSyncNode
->
pFsm
->
FpSnapshotStartWrite
(
pReceiver
->
pSyncNode
->
pFsm
,
&
(
pReceiver
->
pWriter
));
ASSERT
(
ret
==
0
);
if
(
pReceiver
->
pCurrentBlock
!=
NULL
)
{
taosMemoryFree
(
pReceiver
->
pCurrentBlock
);
pReceiver
->
pCurrentBlock
=
NULL
;
pReceiver
->
blockLen
=
0
;
}
pReceiver
->
term
=
pReceiver
->
pSyncNode
->
pRaftStore
->
currentTerm
;
}
else
{
ASSERT
(
0
);
}
}
void
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
)
{
int32_t
ret
=
pReceiver
->
pSyncNode
->
pFsm
->
FpSnapshotStopWrite
(
pReceiver
->
pSyncNode
->
pFsm
,
pReceiver
->
pWriter
,
true
);
ASSERT
(
ret
==
0
);
void
snapshotReceiverDestroy
(
SSyncSnapshotReceiver
*
pReceiver
)
{}
if
(
pReceiver
->
pCurrentBlock
!=
NULL
)
{
taosMemoryFree
(
pReceiver
->
pCurrentBlock
);
pReceiver
->
blockLen
=
0
;
}
}
void
snapshotReceiverStart
(
SSyncSnapshotReceiver
*
pReceiver
)
{}
cJSON
*
snapshotReceiver2Json
(
SSyncSnapshotReceiver
*
pReceiver
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
void
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
)
{}
if
(
pReceiver
!=
NULL
)
{
cJSON_AddNumberToObject
(
pRoot
,
"start"
,
pReceiver
->
start
);
cJSON_AddNumberToObject
(
pRoot
,
"ack"
,
pReceiver
->
ack
);
int32_t
snapshotReceive
(
SSyncSnapshotReceiver
*
pReceiver
)
{
return
0
;
}
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pReceiver
->
pWriter
);
cJSON_AddStringToObject
(
pRoot
,
"pWriter"
,
u64buf
);
cJSON
*
snapshotReceiver2Json
(
SSyncSnapshotReceiver
*
pReceiver
)
{
return
NULL
;
}
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pReceiver
->
pCurrentBlock
);
cJSON_AddStringToObject
(
pRoot
,
"pCurrentBlock"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"blockLen"
,
pReceiver
->
blockLen
);
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
return
NULL
;
}
if
(
pReceiver
->
pCurrentBlock
!=
NULL
)
{
char
*
s
;
s
=
syncUtilprintBin
((
char
*
)(
pReceiver
->
pCurrentBlock
),
pReceiver
->
blockLen
);
cJSON_AddStringToObject
(
pRoot
,
"pCurrentBlock"
,
s
);
taosMemoryFree
(
s
);
s
=
syncUtilprintBin2
((
char
*
)(
pReceiver
->
pCurrentBlock
),
pReceiver
->
blockLen
);
cJSON_AddStringToObject
(
pRoot
,
"pCurrentBlock2"
,
s
);
taosMemoryFree
(
s
);
}
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pReceiver
->
pSyncNode
);
cJSON_AddStringToObject
(
pRoot
,
"pSyncNode"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"replicaIndex"
,
pReceiver
->
replicaIndex
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pReceiver
->
term
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SSyncSnapshotReceiver"
,
pRoot
);
return
pJson
;
}
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
int32_t
syncNodeOnSnapshotSendCb
(
SSyncNode
*
pSyncNode
,
SyncSnapshotSend
*
pMsg
)
{
SSyncSnapshotReceiver
*
pReceiver
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录