Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
70028750
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
70028750
编写于
2月 23, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sync store
上级
6cf9bb57
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
1 deletion
+42
-1
source/libs/sync/inc/syncRaftStore.h
source/libs/sync/inc/syncRaftStore.h
+3
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+1
-1
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+33
-0
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+5
-0
未找到文件。
source/libs/sync/inc/syncRaftStore.h
浏览文件 @
70028750
...
@@ -27,6 +27,9 @@ extern "C" {
...
@@ -27,6 +27,9 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
void
testJson
();
void
testJson2
();
int32_t
currentTerm
(
SyncTerm
*
pCurrentTerm
);
int32_t
currentTerm
(
SyncTerm
*
pCurrentTerm
);
int32_t
persistCurrentTerm
(
SyncTerm
currentTerm
);
int32_t
persistCurrentTerm
(
SyncTerm
currentTerm
);
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
70028750
...
@@ -203,7 +203,7 @@ static int32_t syncIOPing(SSyncIO *io) {
...
@@ -203,7 +203,7 @@ static int32_t syncIOPing(SSyncIO *io) {
rpcMsg
.
pCont
=
rpcMallocCont
(
10
);
rpcMsg
.
pCont
=
rpcMallocCont
(
10
);
snprintf
(
rpcMsg
.
pCont
,
10
,
"ping"
);
snprintf
(
rpcMsg
.
pCont
,
10
,
"ping"
);
rpcMsg
.
contLen
=
10
;
rpcMsg
.
contLen
=
10
;
rpcMsg
.
handle
=
io
;
rpcMsg
.
handle
=
NULL
;
rpcMsg
.
msgType
=
1
;
rpcMsg
.
msgType
=
1
;
rpcSendRequest
(
io
->
clientRpc
,
&
io
->
epSet
,
&
rpcMsg
,
NULL
);
rpcSendRequest
(
io
->
clientRpc
,
&
io
->
epSet
,
&
rpcMsg
,
NULL
);
...
...
source/libs/sync/src/syncRaftStore.c
浏览文件 @
70028750
...
@@ -14,8 +14,41 @@
...
@@ -14,8 +14,41 @@
*/
*/
#include "syncRaftStore.h"
#include "syncRaftStore.h"
#include "cJSON.h"
#include "sync.h"
#include "sync.h"
char
*
serialized
;
void
testJson
()
{
FileFd
raftStoreFd
=
taosOpenFileReadWrite
(
"raft.store"
);
uint64_t
currentTerm
=
100
;
uint64_t
voteFor
=
200
;
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"current_term"
,
currentTerm
);
cJSON_AddNumberToObject
(
pRoot
,
"vote_for"
,
voteFor
);
serialized
=
cJSON_Print
(
pRoot
);
int
len
=
strlen
(
serialized
);
printf
(
"serialized: %s
\n
"
,
serialized
);
taosWriteFile
(
raftStoreFd
,
serialized
,
len
);
taosCloseFile
(
raftStoreFd
);
}
void
testJson2
()
{
cJSON
*
pRoot
=
cJSON_Parse
(
serialized
);
cJSON
*
pCurrentTerm
=
cJSON_GetObjectItem
(
pRoot
,
"current_term"
);
uint64_t
currentTerm
=
pCurrentTerm
->
valueint
;
cJSON
*
pVoteFor
=
cJSON_GetObjectItem
(
pRoot
,
"vote_for"
);
uint64_t
voteFor
=
pVoteFor
->
valueint
;
printf
(
"read json: currentTerm:%lu, voteFor:%lu
\n
"
,
currentTerm
,
voteFor
);
}
int32_t
currentTerm
(
SyncTerm
*
pCurrentTerm
)
{
return
0
;
}
int32_t
currentTerm
(
SyncTerm
*
pCurrentTerm
)
{
return
0
;
}
int32_t
persistCurrentTerm
(
SyncTerm
currentTerm
)
{
return
0
;
}
int32_t
persistCurrentTerm
(
SyncTerm
currentTerm
)
{
return
0
;
}
...
...
source/libs/sync/test/syncTest.cpp
浏览文件 @
70028750
#include <stdio.h>
#include <stdio.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
void
*
pingFunc
(
void
*
param
)
{
void
*
pingFunc
(
void
*
param
)
{
SSyncIO
*
io
=
(
SSyncIO
*
)
param
;
SSyncIO
*
io
=
(
SSyncIO
*
)
param
;
...
@@ -13,6 +14,10 @@ void *pingFunc(void *param) {
...
@@ -13,6 +14,10 @@ void *pingFunc(void *param) {
}
}
int
main
()
{
int
main
()
{
testJson
();
testJson2
();
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录