raftstore

package module
v0.0.0-...-f0b8581 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

raftstore

Raft store implement. Based on github.com/pingcap-incubator/tinykv/kv/raftstore .

Documentation

Index

Constants

View Source
const (
	InitEpochVer     uint64 = 1
	InitEpochConfVer uint64 = 1
)
View Source
const (
	MaxCheckClusterBootstrappedRetryCount = 60
	CheckClusterBootstrapRetrySeconds     = 3
)
View Source
const SnapMgrGcTickInterval = 1 * time.Minute

Variables

This section is empty.

Functions

func BindRespError

func BindRespError(resp *raft_cmdpb.RaftCmdResponse, err error)

func BindRespTerm

func BindRespTerm(resp *raft_cmdpb.RaftCmdResponse, term uint64)

func BootstrapStore

func BootstrapStore(engines *engine_util.Engines, clusterID, storeID uint64) error

func ClearMeta

func ClearMeta(engines *engine_util.Engines, kvWB, raftWB *engine_util.WriteBatch, regionID uint64, lastIndex uint64) error

ClearMeta delete stale metadata like raftState, applyState, regionState and raft log entries

func ClearPrepareBootstrap

func ClearPrepareBootstrap(engines *engine_util.Engines, regionID uint64) error

func ClearPrepareBootstrapState

func ClearPrepareBootstrapState(engines *engine_util.Engines) error

func CreateRaftstore

func CreateRaftstore(cfg *config.Config) (*RaftstoreRouter, *Raftstore)

func ErrResp

func ErrResp(err error) *raft_cmdpb.RaftCmdResponse

func ErrRespRegionNotFound

func ErrRespRegionNotFound(regionID uint64) *raft_cmdpb.RaftCmdResponse

func ErrRespStaleCommand

func ErrRespStaleCommand(term uint64) *raft_cmdpb.RaftCmdResponse

func ErrRespWithTerm

func ErrRespWithTerm(err error, term uint64) *raft_cmdpb.RaftCmdResponse

func NewPeer

func NewPeer(storeId uint64, cfg *config.Config, engines *engine_util.Engines, region *metapb.Region, regionSched chan<- worker.Task,
	meta *metapb.Peer) (*peer, error)

func NotifyReqRegionRemoved

func NotifyReqRegionRemoved(regionId uint64, cb *message.Callback)

func NotifyStaleReq

func NotifyStaleReq(term uint64, cb *message.Callback)

func PrepareBootstrap

func PrepareBootstrap(engins *engine_util.Engines, storeID, regionID, peerID uint64) (*metapb.Region, error)

func PrepareBootstrapCluster

func PrepareBootstrapCluster(engines *engine_util.Engines, region *metapb.Region) error

Types

type ApplySnapResult

type ApplySnapResult struct {
	// PrevRegion is the region before snapshot applied
	PrevRegion *metapb.Region
	Region     *metapb.Region
}

type GlobalContext

type GlobalContext struct {
	// contains filtered or unexported fields
}

type Node

type Node struct {
	// contains filtered or unexported fields
}

func NewNode

func NewNode(system *Raftstore, cfg *config.Config, schedulerClient scheduler_client.Client) *Node

func (*Node) BootstrapCluster

func (n *Node) BootstrapCluster(ctx context.Context, engines *engine_util.Engines, firstRegion *metapb.Region) (newCluster bool, err error)

func (*Node) GetStoreID

func (n *Node) GetStoreID() uint64

func (*Node) Start

func (n *Node) Start(ctx context.Context, engines *engine_util.Engines, trans Transport, snapMgr *snap.SnapManager) error

func (*Node) Stop

func (n *Node) Stop()

type PeerStorage

type PeerStorage struct {

	// Engine include two badger instance: Raft and Kv
	Engines *engine_util.Engines
	// Tag used for logging
	Tag string
	// contains filtered or unexported fields
}

func NewPeerStorage

func NewPeerStorage(engines *engine_util.Engines, region *metapb.Region, regionSched chan<- worker.Task, tag string) (*PeerStorage, error)

NewPeerStorage get the persist raftState from engines and return a peer storage

func (*PeerStorage) Append

func (ps *PeerStorage) Append(entries []eraftpb.Entry, raftWB *engine_util.WriteBatch) error

Append the given entries to the raft log and update ps.raftState also delete log entries that will never be committed

func (*PeerStorage) AppliedIndex

func (ps *PeerStorage) AppliedIndex() uint64

func (*PeerStorage) ApplySnapshot

func (ps *PeerStorage) ApplySnapshot(snapshot *eraftpb.Snapshot, kvWB *engine_util.WriteBatch, raftWB *engine_util.WriteBatch) (*ApplySnapResult, error)

Apply the peer with given snapshot

func (*PeerStorage) ClearData

func (ps *PeerStorage) ClearData()

func (*PeerStorage) Entries

func (ps *PeerStorage) Entries(low, high uint64) ([]eraftpb.Entry, error)

func (*PeerStorage) FirstIndex

func (ps *PeerStorage) FirstIndex() (uint64, error)

func (*PeerStorage) InitialState

func (ps *PeerStorage) InitialState() (eraftpb.HardState, eraftpb.ConfState, error)

func (*PeerStorage) LastIndex

func (ps *PeerStorage) LastIndex() (uint64, error)

func (*PeerStorage) Region

func (ps *PeerStorage) Region() *metapb.Region

func (*PeerStorage) SaveReadyState

func (ps *PeerStorage) SaveReadyState(ready *raft.Ready) (*ApplySnapResult, error)

Save memory states to disk. Do not modify ready in this function, this is a requirement to advance the ready object properly later.

func (*PeerStorage) SetRegion

func (ps *PeerStorage) SetRegion(region *metapb.Region)

func (*PeerStorage) Snapshot

func (ps *PeerStorage) Snapshot() (eraftpb.Snapshot, error)

func (*PeerStorage) Term

func (ps *PeerStorage) Term(idx uint64) (uint64, error)

type PeerTick

type PeerTick int
const (
	PeerTickRaft               PeerTick = 0
	PeerTickRaftLogGC          PeerTick = 1
	PeerTickSplitRegionCheck   PeerTick = 2
	PeerTickSchedulerHeartbeat PeerTick = 3
)

type Raftstore

type Raftstore struct {
	// contains filtered or unexported fields
}

type RaftstoreRouter

type RaftstoreRouter struct {
	// contains filtered or unexported fields
}

func NewRaftstoreRouter

func NewRaftstoreRouter(router *router) *RaftstoreRouter

func (*RaftstoreRouter) Send

func (r *RaftstoreRouter) Send(regionID uint64, msg message.Msg) error

func (*RaftstoreRouter) SendRaftCommand

func (r *RaftstoreRouter) SendRaftCommand(req *raft_cmdpb.RaftCmdRequest, cb *message.Callback) error

func (*RaftstoreRouter) SendRaftMessage

func (r *RaftstoreRouter) SendRaftMessage(msg *raft_serverpb.RaftMessage) error

type StoreTick

type StoreTick int
const (
	StoreTickSchedulerStoreHeartbeat StoreTick = 1
	StoreTickSnapGC                  StoreTick = 2
)

type Transport

type Transport interface {
	Send(msg *rspb.RaftMessage) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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