Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2ef4c421
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
未验证
提交
2ef4c421
编写于
4月 08, 2020
作者:
S
slguan
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1556 from taosdata/feature/sync
Feature/sync
上级
69fec007
e1a3d7f2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
115 addition
and
0 deletion
+115
-0
src/inc/tsync.h
src/inc/tsync.h
+110
-0
src/inc/twal.h
src/inc/twal.h
+5
-0
未找到文件。
src/inc/tsync.h
0 → 100644
浏览文件 @
2ef4c421
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SYNC_H
#define TDENGINE_SYNC_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define TAOS_SYNC_MAX_REPLICA 5
typedef
enum
_TAOS_SYNC_ROLE
{
TAOS_SYNC_ROLE_OFFLINE
,
TAOS_SYNC_ROLE_UNSYNCED
,
TAOS_SYNC_ROLE_SLAVE
,
TAOS_SYNC_ROLE_MASTER
,
}
ESyncRole
;
typedef
enum
_TAOS_SYNC_STATUS
{
TAOS_SYNC_STATUS_INIT
,
TAOS_SYNC_STATUS_START
,
TAOS_SYNC_STATUS_FILE
,
TAOS_SYNC_STATUS_CACHE
,
}
ESyncStatus
;
typedef
struct
{
uint32_t
nodeId
;
// node ID assigned by TDengine
uint32_t
nodeIp
;
// node IP address
char
name
[
TSDB_FILENAME_LEN
];
// external node name
}
SNodeInfo
;
typedef
struct
{
uint32_t
arbitratorIp
;
// arbitrator IP address
int8_t
quorum
;
// number of confirms required, >=1
int8_t
replica
;
// number of replications, >=1
SNodeInfo
nodeInfo
[
TAOS_SYNC_MAX_REPLICA
];
}
SSyncCfg
;
typedef
struct
{
int
selfIndex
;
uint32_t
nodeId
[
TAOS_SYNC_MAX_REPLICA
];
int
role
[
TAOS_SYNC_MAX_REPLICA
];
}
SNodesRole
;
typedef
struct
{
char
label
[
20
];
// for debug purpose
char
path
[
128
];
// path to the file
int8_t
replica
;
// number of replications, >=1
int8_t
quorum
;
// number of confirms required, >=1
int32_t
vgId
;
// vgroup ID
void
*
ahandle
;
// handle provided by APP
uint64_t
version
;
// initial version
uint32_t
arbitratorIp
;
SNodeInfo
nodeInfo
[
TAOS_SYNC_MAX_REPLICA
];
// if name is null, get the file from index or after, used by master
// if name is provided, get the named file at the specified index, used by unsynced node
// it returns the file magic number and size, if file not there, magic shall be 0.
uint32_t
(
*
getFileInfo
)(
char
*
name
,
int
*
index
,
int
*
size
);
// get the wal file from index or after
// return value, -1: error, 1:more wal files, 0:last WAL. if name[0]==0, no WAL file
int
(
*
getWalInfo
)(
char
*
name
,
int
*
index
);
// when a forward pkt is received, call this to handle data
int
(
*
writeToCache
)(
void
*
ahandle
,
SWalHead
*
,
int
type
);
// when forward is confirmed by peer, master call this API to notify app
void
(
*
confirmForward
)(
void
*
ahandle
,
void
*
mhandle
,
int32_t
code
);
// when role is changed, call this to notify app
void
(
*
notifyRole
)(
void
*
ahandle
,
int8_t
role
);
}
SSyncInfo
;
typedef
void
*
tsync_h
;
tsync_h
syncStart
(
SSyncInfo
*
);
void
syncStop
(
tsync_h
shandle
);
int
syncReconfig
(
tsync_h
shandle
,
SSyncInfo
*
);
int
syncForwardToPeer
(
tsync_h
shandle
,
SWalHead
*
pHead
,
void
*
mhandle
);
void
syncConfirmForward
(
tsync_h
shandle
,
uint64_t
version
,
int32_t
code
);
void
syncRecover
(
tsync_h
shandle
);
// recover from other nodes:
int
syncGetNodesRole
(
tsync_h
shandle
,
SNodesRole
*
);
extern
char
*
syncRole
[];
extern
int
tsMaxSyncNum
;
extern
int
tsSyncTcpThreads
;
extern
int
tsMaxWatchFiles
;
extern
short
tsSyncPort
;
extern
int
tsMaxFwdInfo
;
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_SYNC_H
src/inc/twal.h
浏览文件 @
2ef4c421
...
...
@@ -33,6 +33,11 @@ typedef struct {
char
cont
[];
}
SWalHead
;
typedef
struct
{
int8_t
commitLog
;
// commitLog
int8_t
wals
;
// number of WAL files;
}
SWalCfg
;
typedef
void
*
twal_h
;
// WAL HANDLE
twal_h
walOpen
(
char
*
path
,
int
max
,
int
level
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录