Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3e65cacc
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看板
提交
3e65cacc
编写于
5月 14, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(sync): add syncStartStandBy
上级
a2d43fb9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
9 deletion
+32
-9
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+1
-1
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+31
-8
未找到文件。
source/libs/sync/src/syncIO.c
浏览文件 @
3e65cacc
...
...
@@ -15,12 +15,12 @@
#include "syncIO.h"
#include <tdatablock.h>
#include "os.h"
#include "syncMessage.h"
#include "syncUtil.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tutil.h"
#include "os.h"
SSyncIO
*
gSyncIO
=
NULL
;
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
3e65cacc
#include <gtest/gtest.h>
#include <stdio.h>
#include "os.h"
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncUtil.h"
#include "wal.h"
#include "os.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
...
...
@@ -114,7 +114,7 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
pCfg
->
myIndex
=
0
;
pCfg
->
replicaNum
=
1
;
pCfg
->
nodeInfo
[
0
].
nodePort
=
gPorts
[
myIndex
];
taosGetFqdn
(
pCfg
->
nodeInfo
[
myIndex
].
nodeFqdn
);
taosGetFqdn
(
pCfg
->
nodeInfo
[
0
].
nodeFqdn
);
}
else
{
pCfg
->
myIndex
=
myIndex
;
...
...
@@ -148,7 +148,23 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
return
rid
;
}
void
usage
(
char
*
exe
)
{
printf
(
"usage: %s replicaNum myIndex lastApplyIndex writeRecordNum isStandBy
\n
"
,
exe
);
}
void
configChange
(
int64_t
rid
,
int32_t
replicaNum
,
int32_t
myIndex
)
{
SSyncCfg
syncCfg
;
syncCfg
.
myIndex
=
myIndex
;
syncCfg
.
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
syncCfg
.
nodeInfo
[
i
].
nodePort
=
gPorts
[
i
];
taosGetFqdn
(
syncCfg
.
nodeInfo
[
i
].
nodeFqdn
);
}
syncReconfig
(
rid
,
&
syncCfg
);
}
void
usage
(
char
*
exe
)
{
printf
(
"usage: %s replicaNum myIndex lastApplyIndex writeRecordNum isStandBy isConfigChange
\n
"
,
exe
);
}
SRpcMsg
*
createRpcMsg
(
int
i
,
int
count
,
int
myIndex
)
{
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
taosMemoryMalloc
(
sizeof
(
SRpcMsg
));
...
...
@@ -163,7 +179,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
int
main
(
int
argc
,
char
**
argv
)
{
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_SCREEN
+
DEBUG_FILE
;
if
(
argc
!=
6
)
{
if
(
argc
!=
7
)
{
usage
(
argv
[
0
]);
exit
(
-
1
);
}
...
...
@@ -173,12 +189,15 @@ int main(int argc, char** argv) {
int32_t
lastApplyIndex
=
atoi
(
argv
[
3
]);
int32_t
writeRecordNum
=
atoi
(
argv
[
4
]);
bool
isStandBy
=
atoi
(
argv
[
5
]);
bool
isConfigChange
=
atoi
(
argv
[
6
]);
gSnapshotLastApplyIndex
=
lastApplyIndex
;
assert
(
replicaNum
>=
1
&&
replicaNum
<=
5
);
assert
(
myIndex
>=
0
&&
myIndex
<
replicaNum
);
assert
(
lastApplyIndex
>=
-
1
);
assert
(
writeRecordNum
>=
0
);
if
(
!
isStandBy
)
{
assert
(
replicaNum
>=
1
&&
replicaNum
<=
5
);
assert
(
myIndex
>=
0
&&
myIndex
<
replicaNum
);
assert
(
lastApplyIndex
>=
-
1
);
assert
(
writeRecordNum
>=
0
);
}
init
();
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
gPorts
[
myIndex
]);
...
...
@@ -200,6 +219,10 @@ int main(int argc, char** argv) {
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
if
(
isConfigChange
)
{
configChange
(
rid
,
replicaNum
,
myIndex
);
}
//---------------------------
int32_t
alreadySend
=
0
;
while
(
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录