faketikv

package
v2.1.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddNodesDynamic

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

AddNodesDynamic adds nodes dynamically.

func (*AddNodesDynamic) Run

func (w *AddNodesDynamic) Run(driver *Driver) bool

Run implements the event interface.

type Client

type Client interface {
	GetClusterID(ctx context.Context) uint64
	AllocID(ctx context.Context) (uint64, error)
	Bootstrap(ctx context.Context, store *metapb.Store, region *metapb.Region) error
	PutStore(ctx context.Context, store *metapb.Store) error
	StoreHeartbeat(ctx context.Context, stats *pdpb.StoreStats) error
	RegionHeartbeat(ctx context.Context, region *core.RegionInfo) error
	Close()
}

Client is a PD (Placement Driver) client. It should not be used after calling Close().

func NewClient

func NewClient(pdAddr string, tag string) (Client, <-chan *pdpb.RegionHeartbeatResponse, error)

NewClient creates a PD client.

type ClusterInfo

type ClusterInfo struct {
	Nodes map[uint64]*Node
	// contains filtered or unexported fields
}

ClusterInfo records all cluster information.

func NewClusterInfo

func NewClusterInfo(pdAddr string, conf *cases.Conf) (*ClusterInfo, error)

NewClusterInfo creates the initialized cluster with config.

func (*ClusterInfo) GetBootstrapInfo

func (c *ClusterInfo) GetBootstrapInfo(r *RaftEngine) (*metapb.Store, *metapb.Region, error)

GetBootstrapInfo returns a valid bootstrap store and region.

type Config

type Config struct {
}

Config is the faketikv configuration.

type Conn

type Conn struct {
	Nodes map[uint64]*Node
}

Conn records the informations of connection among nodes.

func NewConn

func NewConn(nodes map[uint64]*Node) (*Conn, error)

NewConn returns a conn.

type DeleteNodes

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

DeleteNodes deletes nodes randomly

func (*DeleteNodes) Run

func (w *DeleteNodes) Run(driver *Driver) bool

Run implements the event interface

type Driver

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

Driver promotes the cluster status change.

func NewDriver

func NewDriver(addr string, confName string) *Driver

NewDriver returns a driver.

func (*Driver) AddNode

func (d *Driver) AddNode(id uint64)

AddNode adds a new node.

func (*Driver) Check

func (d *Driver) Check() bool

Check checks if the simulation is completed.

func (*Driver) DeleteNode

func (d *Driver) DeleteNode(id uint64)

DeleteNode deletes a node.

func (*Driver) Prepare

func (d *Driver) Prepare() error

Prepare initializes cluster information, bootstraps cluster and starts nodes.

func (*Driver) Stop

func (d *Driver) Stop()

Stop stops all nodes.

func (*Driver) Tick

func (d *Driver) Tick()

Tick invokes nodes' Tick.

func (*Driver) TickCount

func (d *Driver) TickCount() int64

TickCount returns the simulation's tick count.

type Event

type Event interface {
	Run(driver *Driver) bool
}

Event that affect the status of the cluster

type EventRunner

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

EventRunner includes all events

func NewEventRunner

func NewEventRunner(events []cases.EventInner) *EventRunner

NewEventRunner news a event runner

func (*EventRunner) Tick

func (er *EventRunner) Tick(driver *Driver)

Tick ticks the event run

type Node

type Node struct {
	*metapb.Store
	sync.RWMutex
	// contains filtered or unexported fields
}

Node simulates a TiKV.

func NewNode

func NewNode(s *cases.Store, pdAddr string) (*Node, error)

NewNode returns a Node.

func (*Node) AddTask

func (n *Node) AddTask(task Task)

AddTask adds task in this node.

func (*Node) GetState

func (n *Node) GetState() NodeState

GetState returns current node state.

func (*Node) Start

func (n *Node) Start() error

Start starts the node.

func (*Node) Stop

func (n *Node) Stop()

Stop stops this node.

func (*Node) Tick

func (n *Node) Tick()

Tick steps node status change.

type NodeState

type NodeState int

NodeState node's state.

const (
	Up NodeState = iota
	Down
	LossConnect
	Block
)

some state

type RaftEngine

type RaftEngine struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RaftEngine records all raft infomations.

func NewRaftEngine

func NewRaftEngine(conf *cases.Conf, conn *Conn) (*RaftEngine, error)

NewRaftEngine creates the initialized raft with the configuration.

func (*RaftEngine) GetRegion

func (r *RaftEngine) GetRegion(regionID uint64) *core.RegionInfo

GetRegion returns the RegionInfo with regionID

func (*RaftEngine) GetRegions

func (r *RaftEngine) GetRegions() []*core.RegionInfo

GetRegions gets all RegionInfo from regionMap

func (*RaftEngine) RandRegion

func (r *RaftEngine) RandRegion() *core.RegionInfo

RandRegion gets a region by random

func (*RaftEngine) SearchRegion

func (r *RaftEngine) SearchRegion(regionKey []byte) *core.RegionInfo

SearchRegion searches the RegionInfo from regionTree

func (*RaftEngine) SetRegion

func (r *RaftEngine) SetRegion(region *core.RegionInfo) []*metapb.Region

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 (w *ReadFlowOnRegion) Run(driver *Driver) bool

Run implements the event interface

type Task

type Task interface {
	Desc() string
	RegionID() uint64
	Step(r *RaftEngine)
	IsFinished() bool
}

Task running in node.

type WriteFlowOnRegion

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

WriteFlowOnRegion writes bytes in some region

func (*WriteFlowOnRegion) Run

func (w *WriteFlowOnRegion) Run(driver *Driver) 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 (w *WriteFlowOnSpot) Run(driver *Driver) bool

Run implements the event interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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