TDengine/source/libs/sync/inc/syncRaftLog.h

58 lines
1.9 KiB
C
Raw Normal View History

2022-02-22 03:28:15 +00:00
/*
* 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 _TD_LIBS_SYNC_RAFT_LOG_H
#define _TD_LIBS_SYNC_RAFT_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
2022-02-26 18:24:50 +00:00
#include "syncInt.h"
2022-03-09 06:51:02 +00:00
#include "syncRaftEntry.h"
#include "wal.h"
2022-02-22 03:28:15 +00:00
2022-03-09 06:51:02 +00:00
typedef struct SSyncLogStoreData {
2022-06-27 02:36:28 +00:00
SSyncNode* pSyncNode;
SWal* pWal;
2022-07-07 03:42:45 +00:00
TdThreadMutex mutex;
SWalReader* pWalHandle;
2022-06-27 02:36:28 +00:00
// SyncIndex beginIndex; // valid begin index, default 0, may be set beginIndex > 0
2022-03-09 06:51:02 +00:00
} SSyncLogStoreData;
2022-02-22 03:28:15 +00:00
2022-05-27 10:00:09 +00:00
SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode);
void logStoreDestory(SSyncLogStore* pLogStore);
2022-02-22 03:28:15 +00:00
2022-06-02 11:47:06 +00:00
SyncIndex logStoreFirstIndex(SSyncLogStore* pLogStore);
SyncIndex logStoreWalCommitVer(SSyncLogStore* pLogStore);
SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore);
bool raftLogIsEmpty(struct SSyncLogStore* pLogStore);
SyncIndex raftLogBeginIndex(struct SSyncLogStore* pLogStore);
SyncIndex raftLogEndIndex(struct SSyncLogStore* pLogStore);
int32_t raftLogEntryCount(struct SSyncLogStore* pLogStore);
SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore);
SyncIndex raftLogIndexRetention(struct SSyncLogStore* pLogStore, int64_t bytes);
SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore);
int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry);
2022-03-23 09:08:07 +00:00
2022-02-22 03:28:15 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TD_LIBS_SYNC_RAFT_LOG_H*/