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

57 lines
2 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/>.
*/
2022-02-26 18:24:50 +00:00
#ifndef _TD_LIBS_SYNC_RAFT_ENTRY_H
#define _TD_LIBS_SYNC_RAFT_ENTRY_H
2022-02-22 03:28:15 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2022-02-26 18:24:50 +00:00
#include "syncInt.h"
2022-03-09 10:56:39 +00:00
#include "syncMessage.h"
#include "tskiplist.h"
2022-02-22 03:28:15 +00:00
typedef struct SSyncRaftEntry {
2022-03-09 06:51:02 +00:00
uint32_t bytes;
uint32_t msgType; // TDMT_SYNC_CLIENT_REQUEST
uint32_t originalRpcType; // origin RpcMsg msgType
2022-03-09 10:56:39 +00:00
uint64_t seqNum;
bool isWeak;
2022-03-09 06:51:02 +00:00
SyncTerm term;
SyncIndex index;
int64_t rid;
uint32_t dataLen; // origin RpcMsg.contLen
char data[]; // origin RpcMsg.pCont
2022-02-22 03:28:15 +00:00
} SSyncRaftEntry;
SSyncRaftEntry* syncEntryBuild(int32_t dataLen);
SSyncRaftEntry* syncEntryBuildFromClientRequest(const SyncClientRequest* pMsg, SyncTerm term, SyncIndex index);
SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, SyncIndex index);
SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg);
2022-04-18 13:50:56 +00:00
SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId);
2022-10-31 04:59:42 +00:00
void syncEntryDestroy(SSyncRaftEntry* pEntry);
2024-07-25 08:20:10 +00:00
int32_t syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg); // step 7
2022-03-10 08:54:26 +00:00
static FORCE_INLINE bool syncLogReplBarrier(SSyncRaftEntry* pEntry) {
2023-07-18 08:09:38 +00:00
return pEntry->originalRpcType == TDMT_SYNC_NOOP || pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE;
2022-11-17 09:21:51 +00:00
}
2022-03-09 10:56:39 +00:00
2022-02-22 03:28:15 +00:00
#ifdef __cplusplus
}
#endif
2022-02-26 18:24:50 +00:00
#endif /*_TD_LIBS_SYNC_RAFT_ENTRY_H*/