util

package
v0.0.0-...-3a1a44b Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const InvalidID uint64 = 0
View Source
const RaftInvalidIndex uint64 = 0

Variables

This section is empty.

Functions

func CheckKeyInRegion

func CheckKeyInRegion(key []byte, region *metapb.Region) error

/ Check if key in region range [`start_key`, `end_key`).

func CheckKeyInRegionExclusive

func CheckKeyInRegionExclusive(key []byte, region *metapb.Region) error

/ Check if key in region range (`start_key`, `end_key`).

func CheckKeyInRegionInclusive

func CheckKeyInRegionInclusive(key []byte, region *metapb.Region) error

/ Check if key in region range [`start_key`, `end_key`].

func CheckPeerID

func CheckPeerID(req *raft_cmdpb.RaftCmdRequest, peerID uint64) error

func CheckRegionEpoch

func CheckRegionEpoch(req *raft_cmdpb.RaftCmdRequest, region *metapb.Region, includeRegion bool) error

func CheckStoreID

func CheckStoreID(req *raft_cmdpb.RaftCmdRequest, storeID uint64) error

func CheckTerm

func CheckTerm(req *raft_cmdpb.RaftCmdRequest, term uint64) error

func CloneMsg

func CloneMsg(origin, cloned proto.Message) error

func ConfStateFromRegion

func ConfStateFromRegion(region *metapb.Region) (confState eraftpb.ConfState)

func FindPeer

func FindPeer(region *metapb.Region, storeID uint64) *metapb.Peer

func IsEpochStale

func IsEpochStale(epoch *metapb.RegionEpoch, checkEpoch *metapb.RegionEpoch) bool

/ check whether epoch is staler than check_epoch.

func IsFirstVoteMessage

func IsFirstVoteMessage(msg *eraftpb.Message) bool

/ `is_first_vote_msg` checks `msg` is the first vote message or not. It's used for / when the message is received but there is no such region in `Store::region_peers` and the / region overlaps with others. In this case we should put `msg` into `pending_votes` instead of / create the peer.

func IsInitialMsg

func IsInitialMsg(msg *eraftpb.Message) bool

/ `is_initial_msg` checks whether the `msg` can be used to initialize a new peer or not. There could be two cases:

  1. Target peer already exists but has not established communication with leader yet
  2. Target peer is added newly due to member change or region split, but it's not created yet

For both cases the region start key and end key are attached in RequestVote and Heartbeat message for the store of that peer to check whether to create a new peer when receiving these messages, or just to wait for a pending region split to perform later.

func IsVoteMessage

func IsVoteMessage(msg *eraftpb.Message) bool

func NewTestEngines

func NewTestEngines() *engine_util.Engines

func PeerEqual

func PeerEqual(l, r *metapb.Peer) bool

func RaftstoreErrToPbError

func RaftstoreErrToPbError(e error) *errorpb.Error

func RegionEqual

func RegionEqual(l, r *metapb.Region) bool

func RemovePeer

func RemovePeer(region *metapb.Region, storeID uint64) *metapb.Peer

func SafeCopy

func SafeCopy(b []byte) []byte

Types

type ErrEpochNotMatch

type ErrEpochNotMatch struct {
	Message string
	Regions []*metapb.Region
}

func (*ErrEpochNotMatch) Error

func (e *ErrEpochNotMatch) Error() string

type ErrKeyNotInRegion

type ErrKeyNotInRegion struct {
	Key    []byte
	Region *metapb.Region
}

func (*ErrKeyNotInRegion) Error

func (e *ErrKeyNotInRegion) Error() string

type ErrNotLeader

type ErrNotLeader struct {
	RegionId uint64
	Leader   *metapb.Peer
}

func (*ErrNotLeader) Error

func (e *ErrNotLeader) Error() string

type ErrRegionNotFound

type ErrRegionNotFound struct {
	RegionId uint64
}

func (*ErrRegionNotFound) Error

func (e *ErrRegionNotFound) Error() string

type ErrStaleCommand

type ErrStaleCommand struct{}

func (*ErrStaleCommand) Error

func (e *ErrStaleCommand) Error() string

type ErrStoreNotMatch

type ErrStoreNotMatch struct {
	RequestStoreId uint64
	ActualStoreId  uint64
}

func (*ErrStoreNotMatch) Error

func (e *ErrStoreNotMatch) Error() string

Jump to

Keyboard shortcuts

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