Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0d7272a3
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0d7272a3
编写于
6月 06, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(sync): sending snapshot
上级
84a67e85
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
13 deletion
+26
-13
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+2
-2
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+24
-11
未找到文件。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
0d7272a3
...
...
@@ -284,7 +284,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
)
{
cJSON
*
pJson
=
snapshotSender2Json
(
pSender
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
...
...
@@ -398,7 +398,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
0d7272a3
...
...
@@ -24,6 +24,9 @@ SyncIndex gSnapshotLastApplyIndex;
SyncIndex
gSnapshotLastApplyTerm
;
int
gIterTimes
=
0
;
SyncIndex
gFinishLastApplyIndex
;
SyncIndex
gFinishLastApplyTerm
;
void
init
()
{
int
code
=
walInit
();
assert
(
code
==
0
);
...
...
@@ -111,22 +114,25 @@ int32_t SnapshotDoRead(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32
int32_t
SnapshotStartWrite
(
struct
SSyncFSM
*
pFsm
,
void
**
ppWriter
)
{
*
ppWriter
=
(
void
*
)
0xCDEF
;
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==SnapshotStartWrite== pFsm:%p, *ppWriter:%p"
,
pFsm
,
*
ppWriter
);
sTrace
(
"%s"
,
logBuf
);
return
0
;
}
int32_t
SnapshotStopWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
bool
isApply
)
{
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d"
,
pFsm
,
pWriter
,
isApply
);
sTrace
(
"%s"
,
logBuf
);
if
(
isApply
)
{
gSnapshotLastApplyIndex
=
10
;
gSnapshotLastApplyTerm
=
1
;
gSnapshotLastApplyIndex
=
gFinishLastApplyIndex
;
gSnapshotLastApplyTerm
=
gFinishLastApplyTerm
;
}
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d, gSnapshotLastApplyIndex:%ld, "
"gSnapshotLastApplyTerm:%ld"
,
pFsm
,
pWriter
,
isApply
,
gSnapshotLastApplyIndex
,
gSnapshotLastApplyTerm
);
sTrace
(
"%s"
,
logBuf
);
return
0
;
}
...
...
@@ -258,7 +264,7 @@ void usage(char* exe) {
printf
(
"usage: %s replicaNum(1-5) myIndex(0-..) enableSnapshot(0/1) lastApplyIndex(>=-1) lastApplyTerm(>=0) "
"writeRecordNum(>=0) "
"isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0)
\n
"
,
"isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0)
finishLastApplyIndex(>=-1) finishLastApplyTerm(>=0)
\n
"
,
exe
);
}
...
...
@@ -277,7 +283,7 @@ int main(int argc, char** argv) {
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_ERROR
;
if
(
argc
!=
1
0
)
{
if
(
argc
!=
1
2
)
{
usage
(
argv
[
0
]);
exit
(
-
1
);
}
...
...
@@ -291,12 +297,14 @@ int main(int argc, char** argv) {
bool
isStandBy
=
atoi
(
argv
[
7
]);
bool
isConfigChange
=
atoi
(
argv
[
8
]);
int32_t
iterTimes
=
atoi
(
argv
[
9
]);
int32_t
finishLastApplyIndex
=
atoi
(
argv
[
10
]);
int32_t
finishLastApplyTerm
=
atoi
(
argv
[
11
]);
sTrace
(
"args: replicaNum:%d, myIndex:%d, enableSnapshot:%d, lastApplyIndex:%d, lastApplyTerm:%d, writeRecordNum:%d, "
"isStandBy:%d, isConfigChange:%d, iterTimes:%d"
,
"isStandBy:%d, isConfigChange:%d, iterTimes:%d
, finishLastApplyIndex:%d, finishLastApplyTerm:%d
"
,
replicaNum
,
myIndex
,
enableSnapshot
,
lastApplyIndex
,
lastApplyTerm
,
writeRecordNum
,
isStandBy
,
isConfigChange
,
iterTimes
);
iterTimes
,
finishLastApplyIndex
,
finishLastApplyTerm
);
// check parameter
assert
(
replicaNum
>=
1
&&
replicaNum
<=
5
);
...
...
@@ -306,6 +314,8 @@ int main(int argc, char** argv) {
assert
(
writeRecordNum
>=
0
);
assert
(
isConfigChange
>=
0
&&
isConfigChange
<=
5
);
assert
(
iterTimes
>=
0
);
assert
(
finishLastApplyIndex
>=
-
1
);
assert
(
finishLastApplyTerm
>=
0
);
char
logFile
[
256
];
snprintf
(
logFile
,
sizeof
(
logFile
),
"/tmp/%s-replicaNum%d-myIndex%d.log"
,
gDir
,
replicaNum
,
myIndex
);
...
...
@@ -316,6 +326,9 @@ int main(int argc, char** argv) {
gSnapshotLastApplyTerm
=
lastApplyTerm
;
gIterTimes
=
iterTimes
;
gFinishLastApplyIndex
=
finishLastApplyIndex
;
gFinishLastApplyTerm
=
finishLastApplyTerm
;
init
();
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
gPorts
[
myIndex
]);
assert
(
ret
==
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录