Documentation ¶
Index ¶
- Variables
- func Bootstrap(ctx context.Context, pdAddrs string, store *metapb.Store, ...) (leaderURL string, pdCli pdpb.PDClient, err error)
- func ChooseToHaltPDSchedule(halt bool)
- func PutPDConfig(config *sc.PDConfig) error
- type AddNode
- type Client
- type Connection
- type DownNode
- type Driver
- func (d *Driver) Check() bool
- func (d *Driver) GetBootstrapInfo(r *RaftEngine) (*metapb.Store, *metapb.Region, error)
- func (d *Driver) Prepare() error
- func (d *Driver) RegionsHeartbeat(ctx context.Context)
- func (d *Driver) Start() error
- func (d *Driver) StepRegions(ctx context.Context)
- func (d *Driver) Stop()
- func (d *Driver) StoresHeartbeat(ctx context.Context)
- func (d *Driver) Tick()
- func (d *Driver) TickCount() int64
- type Event
- type EventRunner
- type Node
- type RaftEngine
- func (r *RaftEngine) BootstrapRegion() *core.RegionInfo
- func (r *RaftEngine) GetRegion(regionID uint64) *core.RegionInfo
- func (r *RaftEngine) GetRegionByKey(regionKey []byte) *core.RegionInfo
- func (r *RaftEngine) GetRegionChange(storeID uint64) []uint64
- func (r *RaftEngine) GetRegions() []*core.RegionInfo
- func (r *RaftEngine) NeedSplit(size, rows int64) bool
- func (r *RaftEngine) ResetRegionChange(storeID uint64, regionID uint64)
- func (r *RaftEngine) SetRegion(region *core.RegionInfo) []*core.RegionInfo
- type ReadFlowOnRegion
- type Task
- type WriteFlowOnRegion
- type WriteFlowOnSpot
Constants ¶
This section is empty.
Variables ¶
var ( // PDHTTPClient is a client for PD HTTP API. PDHTTPClient pdHttp.Client // SD is a service discovery for PD. SD sd.ServiceDiscovery )
Functions ¶
func Bootstrap ¶
func Bootstrap(ctx context.Context, pdAddrs string, store *metapb.Store, region *metapb.Region) ( leaderURL string, pdCli pdpb.PDClient, err error)
Bootstrap bootstraps the cluster and using the given PD address firstly. because before bootstrapping the cluster, PDServiceDiscovery can not been started.
func ChooseToHaltPDSchedule ¶
func ChooseToHaltPDSchedule(halt bool)
ChooseToHaltPDSchedule is used to choose whether to halt the PD schedule
func PutPDConfig ¶
PDHTTPClient is a client for PD HTTP API, these are the functions that are used in the simulator
Types ¶
type Client ¶
type Client interface { PutStore(context.Context, *metapb.Store) error StoreHeartbeat(context.Context, *pdpb.StoreStats) error RegionHeartbeat(context.Context, *core.RegionInfo) error Close() // contains filtered or unexported methods }
Client is a PD (Placement Driver) client. It should not be used after calling Close().
type Connection ¶
Connection records the information of connection among nodes.
func NewConnection ¶
NewConnection creates nodes according to the configuration and returns the connection among nodes.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver promotes the cluster status change.
func NewDriver ¶
func NewDriver(pdAddr, statusAddress, caseName string, simConfig *config.SimConfig) (*Driver, error)
NewDriver returns a driver.
func (*Driver) GetBootstrapInfo ¶
GetBootstrapInfo returns a valid bootstrap store and region.
func (*Driver) Prepare ¶
Prepare initializes cluster information, bootstraps cluster and starts nodes.
func (*Driver) RegionsHeartbeat ¶
RegionsHeartbeat sends heartbeat to all regions.
func (*Driver) StepRegions ¶
StepRegions steps regions.
func (*Driver) StoresHeartbeat ¶
StoresHeartbeat sends heartbeat to all stores.
type Event ¶
type Event interface {
Run(raft *RaftEngine, tickCount int64) bool
}
Event affects the status of the cluster.
type EventRunner ¶
EventRunner includes all events.
func NewEventRunner ¶
func NewEventRunner(events []cases.EventDescriptor, raftEngine *RaftEngine) *EventRunner
NewEventRunner creates an event runner.
type Node ¶
Node simulates a TiKV.
func (*Node) GetState ¶
func (n *Node) GetState() metapb.StoreState
GetState returns current node state.
type RaftEngine ¶
RaftEngine records all raft information.
func NewRaftEngine ¶
func NewRaftEngine(conf *cases.Case, conn *Connection, storeConfig *config.SimConfig) *RaftEngine
NewRaftEngine creates the initialized raft with the configuration.
func (*RaftEngine) BootstrapRegion ¶
func (r *RaftEngine) BootstrapRegion() *core.RegionInfo
BootstrapRegion gets a region to construct bootstrap info.
func (*RaftEngine) GetRegion ¶
func (r *RaftEngine) GetRegion(regionID uint64) *core.RegionInfo
GetRegion returns the RegionInfo with regionID.
func (*RaftEngine) GetRegionByKey ¶
func (r *RaftEngine) GetRegionByKey(regionKey []byte) *core.RegionInfo
GetRegionByKey searches the RegionInfo from regionTree
func (*RaftEngine) GetRegionChange ¶
func (r *RaftEngine) GetRegionChange(storeID uint64) []uint64
GetRegionChange returns a list of RegionID for a given store.
func (*RaftEngine) GetRegions ¶
func (r *RaftEngine) GetRegions() []*core.RegionInfo
GetRegions gets all RegionInfo from regionMap
func (*RaftEngine) NeedSplit ¶
func (r *RaftEngine) NeedSplit(size, rows int64) bool
NeedSplit checks whether the region needs to split according its size and number of keys.
func (*RaftEngine) ResetRegionChange ¶
func (r *RaftEngine) ResetRegionChange(storeID uint64, regionID uint64)
ResetRegionChange resets RegionInfo on a specific store with a given Region ID
func (*RaftEngine) SetRegion ¶
func (r *RaftEngine) SetRegion(region *core.RegionInfo) []*core.RegionInfo
SetRegion sets the RegionInfo with regionID
type ReadFlowOnRegion ¶
type ReadFlowOnRegion struct {
// contains filtered or unexported fields
}
ReadFlowOnRegion reads bytes in some region
func (*ReadFlowOnRegion) Run ¶
func (e *ReadFlowOnRegion) Run(raft *RaftEngine, tickCount int64) bool
Run implements the event interface.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task running in node.
func (*Task) Step ¶
func (t *Task) Step(engine *RaftEngine) (isFinished bool)
Step execute once on the Task.
type WriteFlowOnRegion ¶
type WriteFlowOnRegion struct {
// contains filtered or unexported fields
}
WriteFlowOnRegion writes bytes in some region.
func (*WriteFlowOnRegion) Run ¶
func (e *WriteFlowOnRegion) Run(raft *RaftEngine, tickCount int64) bool
Run implements the event interface.
type WriteFlowOnSpot ¶
type WriteFlowOnSpot struct {
// contains filtered or unexported fields
}
WriteFlowOnSpot writes bytes in some range.
func (*WriteFlowOnSpot) Run ¶
func (e *WriteFlowOnSpot) Run(raft *RaftEngine, tickCount int64) bool
Run implements the event interface.