Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyStateKey(regionID uint64) []byte
- func DecodeRegionMetaKey(key []byte) (uint64, byte, error)
- func GetApplyState(db *badger.DB, regionId uint64) (*rspb.RaftApplyState, error)
- func GetRaftEntry(db *badger.DB, regionId, idx uint64) (*eraftpb.Entry, error)
- func GetRaftLocalState(db *badger.DB, regionId uint64) (*rspb.RaftLocalState, error)
- func GetRegionLocalState(db *badger.DB, regionId uint64) (*rspb.RegionLocalState, error)
- func InitApplyState(kvEngine *badger.DB, region *metapb.Region) (*rspb.RaftApplyState, error)
- func InitRaftLocalState(raftEngine *badger.DB, region *metapb.Region) (*rspb.RaftLocalState, error)
- func IsRaftStateKey(key []byte) bool
- func RaftLogIndex(key []byte) (uint64, error)
- func RaftLogKey(regionID, index uint64) []byte
- func RaftStateKey(regionID uint64) []byte
- func RegionMetaPrefixKey(regionID uint64) []byte
- func RegionRaftPrefixKey(regionID uint64) []byte
- func RegionStateKey(regionID uint64) []byte
- func WriteRegionState(kvWB *engine_util.WriteBatch, region *metapb.Region, state rspb.PeerState)
Constants ¶
View Source
const ( // local is in (0x01, 0x02) LocalPrefix byte = 0x01 // We save two types region data in DB, for raft and other meta data. // When the store starts, we should iterate all region meta data to // construct peer, no need to travel large raft data, so we separate them // with different prefixes. RegionRaftPrefix byte = 0x02 RegionMetaPrefix byte = 0x03 RegionRaftPrefixLen = 11 // REGION_RAFT_PREFIX_KEY + region_id + suffix RegionRaftLogLen = 19 // REGION_RAFT_PREFIX_KEY + region_id + suffix + index // Following are the suffix after the local prefix. // For region id RaftLogSuffix byte = 0x01 RaftStateSuffix byte = 0x02 ApplyStateSuffix byte = 0x03 // For region meta RegionStateSuffix byte = 0x01 )
View Source
const ( // When we create a region peer, we should initialize its log term/index > 0, // so that we can force the follower peer to sync the snapshot first. RaftInitLogTerm = 5 RaftInitLogIndex = 5 )
Variables ¶
View Source
var ( MinKey = []byte{} MaxKey = []byte{255} LocalMinKey = []byte{LocalPrefix} LocalMaxKey = []byte{LocalPrefix + 1} RegionMetaMinKey = []byte{LocalPrefix, RegionMetaPrefix} RegionMetaMaxKey = []byte{LocalPrefix, RegionMetaPrefix + 1} // Following keys are all local keys, so the first byte must be 0x01. PrepareBootstrapKey = []byte{LocalPrefix, 0x01} StoreIdentKey = []byte{LocalPrefix, 0x02} )
Functions ¶
func ApplyStateKey ¶
func GetApplyState ¶
func GetRaftLocalState ¶
func GetRegionLocalState ¶
func InitApplyState ¶
func InitRaftLocalState ¶
func IsRaftStateKey ¶
func RaftLogIndex ¶
/ RaftLogIndex gets the log index from raft log key generated by `raft_log_key`.
func RaftLogKey ¶
func RaftStateKey ¶
func RegionMetaPrefixKey ¶
func RegionRaftPrefixKey ¶
func RegionStateKey ¶
func WriteRegionState ¶
func WriteRegionState(kvWB *engine_util.WriteBatch, region *metapb.Region, state rspb.PeerState)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.