meta

package
v0.0.0-...-1338f1b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

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 ApplyStateKey(regionID uint64) []byte

func DecodeRegionMetaKey

func DecodeRegionMetaKey(key []byte) (uint64, byte, error)

func GetApplyState

func GetApplyState(db *badger.DB, regionId uint64) (*rspb.RaftApplyState, error)

func GetRaftEntry

func GetRaftEntry(db *badger.DB, regionId, idx uint64) (*eraftpb.Entry, error)

func GetRaftLocalState

func GetRaftLocalState(db *badger.DB, regionId uint64) (*rspb.RaftLocalState, error)

func GetRegionLocalState

func GetRegionLocalState(db *badger.DB, regionId uint64) (*rspb.RegionLocalState, error)

func InitApplyState

func InitApplyState(kvEngine *badger.DB, region *metapb.Region) (*rspb.RaftApplyState, error)

func InitRaftLocalState

func InitRaftLocalState(raftEngine *badger.DB, region *metapb.Region) (*rspb.RaftLocalState, error)

func IsRaftStateKey

func IsRaftStateKey(key []byte) bool

func RaftLogIndex

func RaftLogIndex(key []byte) (uint64, error)

/ RaftLogIndex gets the log index from raft log key generated by `raft_log_key`.

func RaftLogKey

func RaftLogKey(regionID, index uint64) []byte

func RaftStateKey

func RaftStateKey(regionID uint64) []byte

func RegionMetaPrefixKey

func RegionMetaPrefixKey(regionID uint64) []byte

func RegionRaftPrefixKey

func RegionRaftPrefixKey(regionID uint64) []byte

func RegionStateKey

func RegionStateKey(regionID uint64) []byte

func WriteRegionState

func WriteRegionState(kvWB *engine_util.WriteBatch, region *metapb.Region, state rspb.PeerState)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL