提交 83a40a7f 编写于 作者: L lichuang

[TD-10645][raft]<feature>refactor sync interface

上级 aa438e7a
...@@ -109,33 +109,20 @@ typedef struct SSyncLogStore { ...@@ -109,33 +109,20 @@ typedef struct SSyncLogStore {
SyncIndex (*logLastIndex)(struct SSyncLogStore* logStore); SyncIndex (*logLastIndex)(struct SSyncLogStore* logStore);
} SSyncLogStore; } SSyncLogStore;
typedef struct SSyncServerState {
SyncNodeId voteFor;
SyncTerm term;
SyncIndex commitIndex;
} SSyncServerState;
typedef struct SSyncClusterConfig {
// Log index number of current cluster config.
SyncIndex index;
// Log index number of previous cluster config.
SyncIndex prevIndex;
// current cluster
const SSyncCluster* cluster;
} SSyncClusterConfig;
typedef struct SStateManager { typedef struct SStateManager {
void* pData; void* pData;
int32_t (*saveServerState)(struct SStateManager* stateMng, SSyncServerState* state); // save serialized server state data, buffer will be free by Sync
int32_t (*saveServerState)(struct SStateManager* stateMng, const char* buffer, int n);
int32_t (*readServerState)(struct SStateManager* stateMng, SSyncServerState* state); // read serialized server state data, buffer will be free by Sync
int32_t (*readServerState)(struct SStateManager* stateMng, char** ppBuffer, int* n);
void (*saveCluster)(struct SStateManager* stateMng, const SSyncClusterConfig* cluster); // save serialized cluster state data, buffer will be free by Sync
void (*saveCluster)(struct SStateManager* stateMng, const char* buffer, int n);
const SSyncClusterConfig* (*readCluster)(struct SStateManager* stateMng); // read serialized cluster state data, buffer will be free by Sync
int32_t (*readCluster)(struct SStateManager* stateMng, char** ppBuffer, int* n);
} SStateManager; } SStateManager;
typedef struct { typedef struct {
......
...@@ -50,6 +50,24 @@ typedef struct SSyncRaftEntry SSyncRaftEntry; ...@@ -50,6 +50,24 @@ typedef struct SSyncRaftEntry SSyncRaftEntry;
#endif #endif
#endif #endif
typedef struct SSyncServerState {
SyncNodeId voteFor;
SyncTerm term;
SyncIndex commitIndex;
} SSyncServerState;
typedef struct SSyncClusterConfig {
// Log index number of current cluster config.
SyncIndex index;
// Log index number of previous cluster config.
SyncIndex prevIndex;
// current cluster
const SSyncCluster* cluster;
} SSyncClusterConfig;
typedef struct { typedef struct {
int32_t replica; int32_t replica;
SyncNodeId nodeId[TSDB_MAX_REPLICA]; SyncNodeId nodeId[TSDB_MAX_REPLICA];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册